<template>
  <div class="message_table">
    <el-table :data="data" height="100%" style="width: 100%" v-loading="loading" @row-click="rowclick">
      <el-table-column :label="languageJson.notice.degreeImportance" width="200">
        <template #default="scope">
          <div class="flex">
            <div class="radio_div" :style="`background: ${colors[scope.row.level]}`"></div>
            <div class="text1">{{ levels[scope.row.level] }}</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column :label="languageJson.notice.content" prop="name">
        <template #default="scope">
          <div class="flex">
            <div class="status">
              <img
                v-if="scope.row.check_status == 1"
                src="@/assets/message/yidu.png"
                style="width: 32px; height: 20px"
                alt=""
              />
              <img
                v-if="scope.row.check_status == 0"
                src="@/assets/message/weidu.png"
                style="width: 32px; height: 20px"
                alt=""
              />
            </div>
            <div class="text1">{{ scope.row.message }}</div>
          </div>
        </template>
      </el-table-column>
      <el-table-column :label="languageJson.notice.sendingTime" prop="name" width="180">
        <template #default="scope">
          <div class="text1">{{ scope.row.created_at }}</div>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
import { http } from '@/utils/http'
const props = defineProps({
  data: Array,
  loading: Boolean,
  tabs: Array,
})
const languageJson = inject('languageJson')
const languageType = inject('languageType')
const levels = ref({
  1: languageJson.value.notice.ordinary,
  2: languageJson.value.notice.important,
  3: languageJson.value.notice.warnt,
  4: languageJson.value.notice.success,
})
const colors = { 1: '#3711d8;', 2: '#ff5f58', 3: '#feac2e', 4: '#1cc535' }

const rowclick = row => {
  if (row.check_status == 0) {
    http.get(`/message/read?id=${row.id}`).then(res => {
      row.check_status = 1
    })
  }
}
</script>

<style lang="scss" scoped>
.message_table {
  height: calc(100% - 105px);
}
.flex {
  display: flex;
  align-items: center;
}
.text1 {
  font-family: AlibabaPuHuiTi_2_65_;
  font-size: 14px;
  color: #000;
}

.radio_div {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #3711d8;
  margin-right: 8px;
}

.status {
  margin-right: 8px;
}
</style>

<style>
.message_table thead tr th.el-table__cell {
  height: 36px;
  line-height: 36px;
  padding: 6px 0;
  background-color: #f3f5fd;
}
.message_table tbody tr td.el-table__cell {
  border-color: rgba(55, 17, 216, 0.08);
  padding: 12px 0;
}
.message_table .active_row .el-table__cell {
  border: none;
  background-color: #f8f9fe;
}
.message_table .el-table__expanded-cell {
  background-color: #f8f9fe;
  padding: 8px;
}
.message_table thead tr th.el-table__cell .cell {
  font-family: AlibabaPuHuiTi_2_85_;
  font-size: 14px;
  font-weight: bold;
  color: #666;
}
</style>